package com.wutuo.aggragation.wtservice.controller;


import cn.apestar.core.base.BaseMessage;
import com.wutuo.wtservice.api.UserServiceAPIService;
import com.wutuo.wtservice.api.request.ListUserServiceRequest;
import com.wutuo.wtservice.api.request.UserServiceRequest;
import com.wutuo.wtservice.api.response.UserServiceResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 服务关系表 <br>
 * 详细说明.
 * <p>
 *
 * @author lvh
 * @version 1.0
 */
@RestController @RequestMapping(value = "/userService", produces = "application/json")
public class UserServiceController {

    @Autowired private UserServiceAPIService userServiceService;

    /**
     * 新增服务关系表
     *
     * @param request
     */
    @RequestMapping(value = "/addorUpdate", method = RequestMethod.POST) public Object create(
        @RequestBody @Valid UserServiceRequest request) {

        userServiceService.addorUpdate(request);
        return new BaseMessage();
    }

    /**
     * 删除服务关系表
     *
     * @param userId
     */
    @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public Object del(
        @PathVariable("id") Long id) {

        userServiceService.del(id);
        return new BaseMessage();
    }

    /**
     * 查询服务关系表
     *
     * @param name
     * @return
     */
    @RequestMapping(value = "/lisForPage", method = RequestMethod.POST)
    public List<UserServiceResponse> lisForPage(@RequestBody ListUserServiceRequest request) {

        List list = userServiceService.lisForPage(request);
        return list;
    }
}